package or.exa.cangguan.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import or.exa.cangguan.common.Result;
import or.exa.cangguan.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "权限管理")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    //获取权限
    @ApiOperation(value = "获取权限")
    @PostMapping("/permission/get")
    public Result getPermission(@RequestParam String userName) {
        log.info("获取权限用户名: {}", userName);

        List<String> permission = permissionService.getPermission(userName);
        if (permission == null) {
            return Result.err(501, "获取权限失败");
        }
        return Result.ok(permission);
    }


}
